import doctrine from 'doctrine'
import { ClassTypes } from '../types/class'
import { FunctionTypes } from '../types/func'
import { ASTResult } from '../types/ops'
export function preseComment(comment: string) {
  if (!comment) return undefined
  if (typeof comment === 'function') return undefined
  return doctrine.parse(comment, {
    unwrap: true,
  })
}

export function getParams(item: ASTResult):
  | {
      name: string
      type: string
    }[]
  | undefined {
  const result = (item as FunctionTypes).params ? (item as FunctionTypes).params : (item as ClassTypes).constructorInfo.params
  return result
}
